#include <iostream>
#include "windows.h"
#include "WWwindows.h"

HWND gHWND1 = nullptr;

LRESULT CALLBACK WindowProc(HWND, UINT, WPARAM, LPARAM);

inline void setGlobalHWND(ww::Windows& w, HWND& hwnd) { hwnd = w.getHWND(); } ;

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
    PSTR pCmdLine, int nShowCmd)
{
	ww::Windows myWindows(WindowProc, hInstance, "Sugee", nShowCmd); 
	myWindows.InitializeNormalWindows();
	setGlobalHWND(myWindows, gHWND1);

	try
	{
	return myWindows.Run();
	}
	catch(ww::WindowsNotInitializedException ex) {}

}

LRESULT CALLBACK
WindowProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
    // Handle some specific messages. Note that if we handle a
    // message, we should return 0.
    switch( msg )
    {
        // In the case the left mouse button was pressed,
        // then display a message box.
    case WM_LBUTTONDOWN:
        MessageBox(0, L"Hello, World", L"Hello", MB_OK);
        return 0;

        // In the case the Escape key was pressed, then
        // destroy the main application window.
    case WM_KEYDOWN:
        if( wParam == VK_ESCAPE )
            DestroyWindow(gHWND1);
        return 0;

        // In the case of a destroy message, then send a
        // quit message, which will terminate the message loop.
    case WM_DESTROY:
        PostQuitMessage(0);
        return 0;
    }

    // Forward any other messages we did not handle above to the
    // default window procedure. Note that our window procedure
    // must return the return value of DefWindowProc.
    return DefWindowProc(hWnd, msg, wParam, lParam);
}
